package com.arron.algorithm;

/**
 * @Classname Test2
 * @Date 2020/9/10 20:47
 * @Created by 刘
 */

abstract class A{
    int a = 1;
    abstract void a();
    class Inner extends A{
        @Override
        void a() {

        }
    }
}


public class Test2 {

    public static void main(String[] args) {

//        A a = new A() {
//            @Override
//            void a() {
//
//            }
//        };
//        get(a);
//        System.out.println(f0(2, 3));

        //求n!

        System.out.println(f1(5));

    }

    public static A get(A s){
        A a = new A() {
            @Override
            void a() {

            }
        };
        return a;
    }

    //计算组合函数C(r,n)，
    public static int f0(int r,int n){
        return f1(n)/f1(r);
    }

    //求阶乘函数,非递归解法
    public static int f1(int a){
        if (a ==1 || a ==2){
            return a;
        }
        int result =1;
        while (a>0){
            result *= a--;
        }
        return  result;
    }


}
